package net.daum.webtoon.android.dto;

import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

public class DTO_Artist extends JSonDataObjectBase {
	public String TAG = getClass().getSimpleName();

	public String artistType;

	public String teamYn;
	public String career;
	public String authUserinfo;

	public String birthDay;
	public String team;
	public String blog;
	public String debutDay;
	public String homepage;
	public String fancafe;

	public String history;
	public String id;
	public String email;
	public String joinDay;
	public String penName;
	public String name;
	public String cafe;
	public String artistOrder;
	public String breakDay;
	public String introduction;

	public DTO_PictureImage pictureImage;
	public DTO_PictureImage smallPictureImage;
	public DTO_PictureImage nameImage;

	public DTO_Artist(JSONObject aJsonObject) {
		Iterator<Object> iterator = aJsonObject.keys();

		while (iterator.hasNext()) {
			Object obj = iterator.next();
			if (obj.toString().equalsIgnoreCase("nameImage")) {
				try {
					if (aJsonObject.has("nameImage")) {
						this.nameImage = new DTO_PictureImage(aJsonObject.getJSONObject("nameImage"));
						this.nameImage.printMembers();
					}
				} catch (JSONException e) {
					this.nameImage = null;
					if (isDebug)
						e.printStackTrace();
				}
			} else if (obj.toString().equalsIgnoreCase("pictureImage")) {
				try {
					if (aJsonObject.has("pictureImage")) {
						this.pictureImage = new DTO_PictureImage(aJsonObject.getJSONObject("pictureImage"));
						this.pictureImage.printMembers();
					}
				} catch (JSONException e) {
					this.pictureImage = null;
					if (isDebug)
						e.printStackTrace();
				}
			} else if (obj.toString().equalsIgnoreCase("smallPictureImage")) {
				try {
					if (aJsonObject.has("smallPictureImage")) {
						this.smallPictureImage = new DTO_PictureImage(aJsonObject.getJSONObject("smallPictureImage"));
						this.smallPictureImage.printMembers();
					}
				} catch (JSONException e) {
					this.smallPictureImage = null;
					if (isDebug)
						e.printStackTrace();
				}
			} else {
				setMemberFiled(this, aJsonObject, obj.toString());
			}
		}

		printMembers();
		insertObjToDB();
	}
}
